package com.AAA.controller.sds;

import com.AAA.entity.*;
import com.AAA.entity.sds.TTestRecondSds;
import com.AAA.entity.sds.TTestRecondSds1;
import com.AAA.service.sds.TTestRecondSdsService;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * (TTestRecondSds)表控制层
 *
 * @author makejava
 * @since 2022-11-04 16:23:26
 */
@RestController
@RequestMapping("tTestRecondSds")
public class TTestRecondSdsController {
    /**
     * 服务对象
     */
    @Autowired
    private TTestRecondSdsService service;

    @PostMapping("add")
    private LayData add(HttpServletRequest request, HttpSession session){
        String username = request.getParameter("username");
        Integer id = service.selectidbyusername(username);
        Integer rid = service.selectusernameidbyusername(id);
        if (rid>0){
            return new LayData(false);
        }
        return new LayData(service.add(request,session));
    }
    //分页查询
    @GetMapping("selectall")
    public  LayData selectall(MyPage myPage, TTestRecondSds1 tTestRecondSds){
        return  new LayData(service.selectall(myPage,tTestRecondSds));
    }
    //修改
    @PostMapping ("update")
    public LayData update(TTestRecondSds tTestRecondSds,HttpSession session){
        User user = (User) session.getAttribute("user");
        tTestRecondSds.setUpdateby(user.getUsername());
        return new LayData(service.update(tTestRecondSds));
    }
    //删除
    @PostMapping("del")
    @ResponseBody
    public LayData delete(Integer id){
        return new LayData( service.delete(id));
    }




}